<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="kygcxx">
    <meta name="author" content="xxf">
    <title><?php echo $title; ?></title>
    <link href="sb2/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="sb2/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="css/login.css" rel="stylesheet">
</head>

<body>
<div class="box">
		<div class="login-box">
			<div class="login-title text-center">
				<h1><small>注册</small></h1>
			</div>
			<div class="login-content ">
			<div class="form">
			<form action="<?php echo $_url; ?>register" method="post" >
				<div class="form-group">
					<div class="col-xs-8  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
							<input type="text" id="uname" name="uname" class="form-control" placeholder="用户名" required autocomplete="off">
						</div>
					</div>
					<div class="col-xs-4  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-refresh"></span></span>
							<input type="button" id="youxiao" name="youxiao" class="form-control"   value="有效性验证">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-xs-8  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-phone"></span></span>
							<input type="text" id="shouji" name="shouji" class="form-control" readonly placeholder="手机号" required autocomplete="off">
						</div>
					</div>
					<div class="col-xs-4  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-signal"></span></span>
							<input type="button" id="send" name="send" class="form-control"  disabled value="获取验证码">
						</div>
					</div>
				</div>
				<div class="form-group">
					<div class="col-xs-12  ">
						<div class="input-group">
							<span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span>
							<input type="text" id="yzm" name="yzm" class="form-control" readonly placeholder="验证码" required autocomplete="off">
						</div>
					</div>
				</div>
				<div class="form-group form-actions">
					<div class="col-xs-4 col-xs-offset-4 ">
						<input type="hidden" value="<?php echo $_token; ?>" name="_token">
						<input type="hidden" value="register" name="type">
						<button type="submit" class="btn btn-sm btn-info" id="submit" disabled><span class="glyphicon glyphicon-upload"></span> 注册</button>
					</div>
				</div>
				<div class="form-group">
					<div class="col-xs-6 link">
						<p class="text-center remove-margin"><small>注册须知</small> <a href="javascript:$(function(){$.xalert($.gc('notice'),'#FF0000')});" ><small>查看</small></a>
						</p>
					</div>
					<div class="col-xs-6 link">
						<p class="text-center remove-margin"><small>返回</small> <a href="/" ><small>登陆</small></a>
						</p>
					</div>
				</div>
			</form>
			</div>
		</div>
	</div>
</div>
    <script src=js/jquery-3.1.1.min.js></script>
    <script src=js/bootstrap.min.js></script>
    <script src=js/jquery.xxfset.js></script>
    <script src=js/app.js></script>
    <script type="text/javascript">
    $(function(){
    	$('#youxiao').click(function(){
			$uname=$("#uname").val();
			if(/^[A-Za-z0-9]+$/.test($uname)&&$uname.length>4) {
				$.xloading(1);
				$.post($.gu("register"),{type:"youxiao",uname:$uname},function(data){
					$.xloading(0);
					if(data){
						$.xalert("用户名["+$uname+"]已被占用，请重新输入！");
					}else{
						$.xalert("恭喜你，用户名["+$uname+"]可用，请进行下一步操作！");
						$(this).attr("readonly",true).attr("disabled",true);
						$('#uname').attr("readonly",true);
						$('#shouji').attr("readonly",false);
						$('#send').attr("readonly",false).attr("disabled",false);
					}
				});
			}else{
				$.xalert("用户名只能由英文和数字组成，且长度不能低于5位！");
			}
        });
    	$('#send').click(function(){
        	$sj=$("#shouji").val();
			if(/^1[34578]\d{9}$/.test($sj)){
				$.xloading(1);
				$.post($.gu("register"),{type:"send",shouji:$sj},function(data){
					if(data){
						$.xloading(0);
						$.xalert("该手机号码已被注册，请更换注册号码或通过登陆页面找回密码！");
					}else{
						$.ajax({url:$.gu("sms"),data:{shouji:$sj	},type:"post",	dataType:"text",success:function(data1){
    						$.xloading(0);
    						if(data1==1){
    							$('#yzm').attr("readonly",false);
    							$('#submit').attr("readonly",false).attr("disabled",false);
    							$('#shouji').attr("readonly",true);
    							$('#send').attr("readonly",true).attr("disabled",true);
    							$.xalert("验证码发送成功，请填入收到的4位验证码！");
    						}else if(data1==0){
    							$.xalert("发送失败，请重试！");
    						}else{
    							alert(data1)
    						}
    					}});
					}
				});
			}else{
				$.xalert("请输入正确的手机号码！");
			}
        });
    	$('#submit').click(function(){
        	$yzm=$("#yzm").val();
        	if($yzm.length==4){
        		$.xloading(1);
        		return true;
            }else{
				$.xalert("请输入收到的4位数字验证码！");
				return false;
            }
        });
    });
    </script>
</body>

</html>